﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<eCRAM.WebSite.Models.PrintCramModel>" %>

<%@ Import Namespace="eCRAM.Model" %>
<%@ Import Namespace="eCRAM.Tools" %>
<%@ Import Namespace="System.Globalization" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Aperçu avant Impression</title>
    <link href="../../Content/Print.css" rel="stylesheet" type="text/css" />
    
</head>
<body>
   <div class="page">
   
   <div>  
    <table width="100%" style="border-style: hidden; border-width: 0px">
      <tr>
      <td width="20%" >
        <img src="../../Content/Images/Logo APTEA.gif" style="height: 83px" />
      </td>
      <td width="80%">
      <h1  style="width: 830px" align="center">COMPTE-RENDU D'ACTIVITÉ MENSUELLE (CRAM)</h1>
      </td>
      </tr>
    </table>
   </div>
   
        <div id="main" >
           <%-- <fieldset>--%>
                
                <table id="UserTable" frame="border" 
                style="border-style: hidden; border-width: 0px">
                    <tr>
                        <td >
                            <b>Utilisateur :</b>
                        </td>
                        <td>
                            <%=Html.Encode(Model.UserName.Capitalize()) %>
                        </td>
                        <td>
                            <b>Mois :</b>
                        </td>
                        <td>
                            <%
                                var formatInfoinfo = CultureInfo.CurrentCulture.DateTimeFormat;
                            %>
                            <%=Html.Encode(formatInfoinfo.MonthNames[Model.Month - 1].Capitalize())%>
                        </td>
                        <td>
                            <b>Année :</b>
                        </td>
                        <td>
                            <%=Html.Encode(Model.Year)%>
                        </td>
                    </tr>
                </table>
                <br />
                <br />
           <%-- </fieldset>--%>
            <%--<fieldset>--%>
                <%         
                    var cramDate = new DateTime(Model.Year != 0 ? Model.Year : DateTime.Now.Year, Model.Month != 0 ? Model.Month : DateTime.Today.Month, 1);
                    var workingDays = WorkingDay.MonthWorkingDays(cramDate.Year, cramDate.Month);

                    // Liste des jours
                    var strWorkingDays = string.Join(", ", workingDays.Select(x => (x ? "1" : "0")));
                    Response.Write(Html.Hidden("hidDays", strWorkingDays));
                %>
                <table id="tableCram" class="CramGrid">
                    <thead>
                        <th class="CellCramTitleHeader">
                            Projet / Mission
                        </th>
                        <%                   
                            for (int i = 1; i <= workingDays.Count; i++)
                            {
                                Response.Write(string.Format("<th class='cellDayHeader'>{0}</th>", Html.Encode(i)));
                            } 
                        %>
                        <th class='cellDayHeader'>
                            Total
                        </th>
                    </thead>
                    <%
                        if (Model.CramlinesModel != null && Model.CramlinesModel.Count > 0)
                        {

                            Response.Write(Html.Hidden("id", ""));
                            foreach (var item in Model.CramlinesModel)
                            {
                                Response.Write(string.Format("<tr id='tr_{0}'>", item.Activity.Id)); %>
                    <%-- <td>
                        <%= Html.Hidden(string.Format("idCramLine_{0}", item.Activity.Id), item.Id)%>
                        <%= Html.Hidden(string.Format("StatusCramLine_{0}", item.Activity.Id), item.Status)%>
                        <%= Html.Image(string.Format("delete_{0}", item.Activity.Id), "~/Content/Images/delete.png","Supprimer", "CramTable", "return;")%>
                    </td>--%>
                    <td>
                        <%=Html.Encode(item.Activity.Name)%>
                    </td>
                    <%
int k = 0;
foreach (var rate in item.Rates)
{
    var idTextbox = string.Format("day_{0}_{1}", k + 1, item.Activity.Id);
    var className = "PrintDay";
    var cellClassName = "PrintCellDay";
    if (!workingDays[k])
    {
        cellClassName = "PrintCellHoliday";
        className = "PrintHoliday";
    }

    //if (item.Status != (int)CramStatus.New)
    {
        cellClassName = "Readonly" + cellClassName;
        className = "Readonly" + className;
    }

    Response.Write(string.Format("<td class='{0}'>", cellClassName));
    Response.Write(Html.TextBox(idTextbox, rate.Value == 0 ? "" : rate.Value == 0.5m ? "½" : rate.Value.ToString("0.#"),
                                new
                                    {
                                        @readonly = "readonly",
                                        MaxLength = 3,
                                        @class = className
                                    }));
    Response.Write("</td>");

    k++;
}

                    %>
                    <td class="PrintReadonlyCellDay">
                        <%=Html.TextBox(string.Format("Total_{0}", item.Activity.Id), item.Total.ToString("0.#"), new { @readonly = "readonly", @class = "totalActivity" })%>
                    </td>
                    <% Response.Write("</tr>");
                    }
                }%>
                </table>
            <%--</fieldset>--%>
            <%--<fieldset>--%>
            <div style="position:absolute; top:400px;width : 900px">
                <table align="left" class="TableMetrics">
                    <tr>
                        <td>
                            <b>Jours travaillés : </b>
                        </td>
                        <td class="CellMetrics">
                            <input id="txtTotalWorkedDays" type="text" readonly="readonly" class="totalActivity"
                                value="<%=Html.Encode(Model.WorkedDays.ToString("0.#"))%>" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <b>Jours d'absence : </b>
                        </td>
                        <td class="CellMetrics">
                            <input id="txtTotalHolidays" type="text" readonly="readonly" class="totalActivity"
                                value="<%=Html.Encode(Model.VacationDays.ToString("0.#"))%>">
                                <%----%>
                            </input>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <b>Jours ouvrés : </b>
                        </td>
                        <td class="CellMetrics">
                            <input id="txtTotalWorkingDays" type="text" readonly="readonly" class="totalActivity"
                                value="<%=Html.Encode(Model.WorkingDays.ToString("0.#"))%>" />
                        </td>
                    </tr>
                </table>
                <table align="right" class="TableDownload">
                    <tr>
                        <td class="CellFieldSign">
                            <fieldset class="CellSign">
                                <legend>Collaborateur</legend>
                            </fieldset>
                        </td>
                        <td class="CellFieldSign">
                            <fieldset class="CellSign">
                                <legend>Aptea</legend>
                            </fieldset>
                        </td>
                        <td class="CellFieldSign">
                            <fieldset class="CellSign">
                                <legend>Client</legend>
                            </fieldset>
                        </td>
                    </tr>
                </table>
                </div>
               
            <%--</fieldset>--%>
        </div>
    </div>

</body>
</html>
